package com.mydomain.Bodega;

import com.mydomain.Bodega.*;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;
import java.util.List;

@Name("invIngresoList")
public class InvIngresoList extends EntityQuery<InvIngreso> {

	private String EJBQL = "select invIngreso from InvIngreso invIngreso join invIngreso.invProveedor p  ";
	
	

	private static final String[] RESTRICTIONS = { 
		" lower(invIngreso.ingObservacion) like concat(lower(#{invIngresoList.invIngreso.ingObservacion}),'%') ",
	 	"  cast(invIngreso.ingCodigo as string) like concat(lower(#{invIngresoList.invIngreso.buscadorIngCodigo}),'%') ",
	 	"  cast(p.proCodigo as string) like concat(lower(#{invIngresoList.invIngreso.buscadorProveedor}),'%') ",
			};

	private InvIngreso invIngreso = new InvIngreso();
	
	public InvIngresoList() {
		Subdepartamento usuario = (Subdepartamento) getSessionContext().get(
				"usuarioLogeo");
		EJBQL = EJBQL
				+ " join  invIngreso.subdepartamento s  where invIngreso.depCodigo="
				+ usuario.getDepartamento().getDepCodigo()
				+ " and s.subdepCodigo=" + usuario.getSubdepCodigo();
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public InvIngreso getInvIngreso() {
		return invIngreso;
	}
}
